package com.core.Interceptor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

/**
 * 全局异常拦截器
 * 
 * @author pt-chenqw
 *
 */
@Component
public class GlobalExceptionInteceptor implements Interceptor {
	
	private static Logger log = LoggerFactory.getLogger(GlobalExceptionInteceptor.class);
	
	private static final long serialVersionUID = 1L;

	@Override
	public void destroy() {}

	@Override
	public void init() {}

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		String result = null;
		try {
			result = invocation.invoke();
		} catch (Exception e) {
			log.error("Struts2 拦截到错误,错误信息是" + e.getMessage());
		}
		return result;
	}
	
}
